﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WebUI.Models;
using DomainModel;
using Utils;
using System.Web.Mvc;

namespace WebUI.Utils
{
    public class JsonResultModelHelper
    {
        public static JsonResultModel ForSuccess()
        {
            return new JsonResultModel(JsonResultType.Success, true, string.Empty, string.Empty, null);
        }

        public static JsonResultModel ForSuccessWithRedirectUrl( string redirectUrl)
        {
            return new JsonResultModel(JsonResultType.SuccessWithRedirectUrl, true, redirectUrl, string.Empty, null);
        }

        public static JsonResultModel ForSuccessWithSummaryMessage(string summaryMessage)
        {
            return new JsonResultModel(JsonResultType.SuccessWithSummaryMessage, true, string.Empty, summaryMessage, null);
        }

        public static JsonResultModel ForSuccess(string redirectUrl, string summaryMessage)
        {
            return new JsonResultModel(JsonResultType.SuccessWithRedirectUrlAndSummaryMessage, true, redirectUrl, summaryMessage, null);
        }

        public static JsonResultModel ForError()
        {
            return new JsonResultModel(JsonResultType.Error, false, string.Empty, string.Empty, null);
        }

        public static JsonResultModel ForError(string summaryMessage)
        {
            return new JsonResultModel(JsonResultType.ErrorWithSummaryMessage, false, string.Empty, summaryMessage, null);
        }

        public static JsonResultModel ForError(ModelStateDictionary modelState)
        {
            return new JsonResultModel(JsonResultType.ErrorWithModelStateErrors, false, string.Empty, string.Empty, modelState);
        }

        public static JsonResultModel ForError(string summaryMessage, ModelStateDictionary modelState)
        {
            return new JsonResultModel(JsonResultType.ErrorWithSummaryMessageAndModelStateErrors, false, string.Empty, summaryMessage, modelState);
        }

        public static JsonResultModel ForError(string redirectUrl, string summaryMessage)
        {
            return new JsonResultModel(JsonResultType.ErrorWithRedirectUrlAndSummaryMessage, false, redirectUrl, summaryMessage, null);
        }
    }

    public class JsonResultUploadFileModelHelper
    {
        public static JsonResultUploadFileModel ForSuccess()
        {
            return new JsonResultUploadFileModel(JsonResultUploadFileType.Success, true, string.Empty, string.Empty, string.Empty, null); 
        }

        public static JsonResultUploadFileModel ForSuccessWithFilePath(string filePath)
        {
            return new JsonResultUploadFileModel(JsonResultUploadFileType.SuccessWithFilePath, true, filePath, string.Empty, string.Empty, null); 
        }

        public static JsonResultUploadFileModel ForSuccessWithRedirectUrl(string redirectUrl)
        {
            return new JsonResultUploadFileModel(JsonResultUploadFileType.SuccessWithRedirectUrl, true, string.Empty, redirectUrl, string.Empty, null);
        }

        public static JsonResultUploadFileModel ForSuccessWithSummaryMessage(string summaryMessage)
        {
            return new JsonResultUploadFileModel(JsonResultUploadFileType.SuccessWithSummaryMessage, true, string.Empty, string.Empty, summaryMessage, null);
        }

        public static JsonResultUploadFileModel ForSuccessWithFilePathAndSummaryMessage(string filePath, string summaryMessage)
        {
            return new JsonResultUploadFileModel(JsonResultUploadFileType.SuccessWithFilePathAndSummaryMessage, true, filePath, string.Empty, summaryMessage, null);
        }

        public static JsonResultUploadFileModel ForSuccessWithRedirectUrlAndSummaryMessage(string redirectUrl, string summaryMessage)
        {
            return new JsonResultUploadFileModel(JsonResultUploadFileType.SuccessWithFilePathAndSummaryMessage, true, string.Empty, redirectUrl, summaryMessage, null);
        }

        public static JsonResultUploadFileModel ForError()
        {
            return new JsonResultUploadFileModel(JsonResultUploadFileType.Error, false, string.Empty, string.Empty, string.Empty, null);
        }

        public static JsonResultUploadFileModel ForError(string summaryMessage)
        {
            return new JsonResultUploadFileModel(JsonResultUploadFileType.ErrorWithSummaryMessage, false, string.Empty, string.Empty, summaryMessage, null);
        }

        public static JsonResultUploadFileModel ForError(ModelStateDictionary modelState)
        {
            return new JsonResultUploadFileModel(JsonResultUploadFileType.ErrorWithModelStateErrors, false, string.Empty, string.Empty, string.Empty, modelState);
        }

        public static JsonResultUploadFileModel ForError(string summaryMessage, ModelStateDictionary modelState)
        {
            return new JsonResultUploadFileModel(JsonResultUploadFileType.ErrorWithSummaryMessageAndModelStateErrors, false, string.Empty, string.Empty, summaryMessage, modelState);
        }

        public static JsonResultUploadFileModel ForError(string redirectUrl, string summaryMessage)
        {
            return new JsonResultUploadFileModel(JsonResultUploadFileType.ErrorWithRedirectUrlAndSummaryMessage, false, string.Empty, redirectUrl, summaryMessage, null);
        }
    }
}